﻿using System.Collections.Generic;

namespace System.Xml.Serialization
{
    public interface IXmlData
    {
    }

    public interface IXmlObjectSerializer<T>
    {
        void Serialize(object value);
        void Deserialize(object value);
    }

    public interface IXmlObjectSerializer : IXmlRuntimeSerializer
    {
        IXmlObjectSerializer Create(object value, string name);
        IXmlObjectSerializer Add(object value, string name);
        IXmlObjectSerializer Remove(object value, string name);

        void Add(IXmlObjectSerializer serializer);
        void Remove(IXmlObjectSerializer serializer);

        IEnumerable<IXmlObjectSerializer> Elements { get; }

        int Id { get; }
        string Name { get; }

        IXmlObjectAttributeSerializer Attributes { get; }

        string this[string propertyName] { get; set; }
    }

    public interface IXmlObjectAttributeSerializer
    {
        string this[string attributeName] { get; set; }
    }

    public interface IXmlRuntimeSerializer
    {
        void Serialize(Type type, object value);
        void Deserialize(Type type, object value);
        void Serialize(object value);
        void Deserialize(object value);

        IXmlObjectSerializer<T> GetSerializer<T>();
    }

    public interface IXmlObjectAttributeReader
    {
        string this[string attributeName] { get; }
    }

    public interface IXmlObjectAttributeWriter
    {
        string this[string attributeName] { set; }
    }

    public interface IXmlAttributeReader
    {
        IXmlObjectAttributeReader ReadAttributes { get; }
    }

    public interface IXmlAttributeWriter
    {
        IXmlObjectAttributeWriter WriteAttributes { get; }
    }

    public delegate T Factory<T>();

    public interface IXmlPropertyReader : IXmlAttributeReader
    {
        IEnumerable<T> Read<T>(string propertyName, Factory<T> constructor);
        string Read(string propertyName);
    }

    public interface IXmlPropertyWriter : IXmlAttributeWriter
    {
        void Write<T>(string propertyName, IEnumerable<T> objects);
        void Write(string propertyName, string value);
    }

    public interface IXmlSerializer<T>
    {
        T Deserialize(IXmlPropertyReader reader, string propertyName);
        void Serialize(IXmlPropertyWriter writer, string propertyName, T value);
    }

    public interface IXmlRuntimeSerializer<T>
    {
        T Deserialize(IXmlPropertyReader reader, string propertyName);
        void Serialize(T value, IXmlPropertyWriter writer, string propertyName);
    }

    public interface IXmlFileSerializer<T>
    {
        T Deserialize(string fileName);
        T Deserialize(string fileName, IXmlRuntimeFormatter formatter);
        void Serialize(T obj, string fileName);
        void Serialize(T obj, string fileName, IXmlRuntimeFormatter formatter);
    }

    public interface IXmlFormatAttributes
    {
        XmlAttributeOverrides Format { get; }
    }

    public interface IXmlRuntimeFormatter : IXmlTypeFormatter
    {
        void AddOverrides(IXmlTypeFormatter formatter);
    }

    public interface IXmlTypeFormatter
    {
        IXmlTypeSerializer Serializer { get; }
    }

    public interface IXmlTypeSerializer<T, U>
    {
        U Serialize(T obj);
        U Serialize(T obj, IXmlRuntimeFormatter serializer);
        T Deserialize(U store);
        T Deserialize(U store, IXmlRuntimeFormatter serializer);
    }

    public interface IXmlTypeSerializer
    {
        XmlReaderSettings ReaderSettings { get; }
        XmlWriterSettings WriterSettings { get; }
        IXmlFormatAttributes Attributes { get; }
    }
}